<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
model('jy_scrm/model')->check_worker('',true);
if($_RQ['op']=='main'){
	$item=pdo_get('jy_scrm_worker',array('userid'=>$_SESSION['openid'],'uniacid'=>$_SESSION['uniacid']));
	$item['member']=cfc('core')->member_show($_SESSION['uid']);
	$item['avatar']=$item['avatar']?:$item['member']['avatar'];
	$item['name']=$item['name']?:$item['member']['nickname'];
	$item['mobile']=$item['mobile']?:$item['member']['mobile'];
	$item['worklognum']=pdo_count('jy_workliu_worklog',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$item['tasknum']=pdo_count('jy_workliu_task',array('uniacid'=>$_SESSION['uniacid'],'getmid'=>$_SESSION['uid']));	
	$item['tasklognum']=pdo_count('jy_workliu_tcplog',array('uniacid'=>$_SESSION['uniacid'],'setmid'=>$_SESSION['uid']));
	$item['genjinnum']=pdo_count('jy_scrm_worker_linelog',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$item['id']));
	$return['item']=$item;
	$return['optype']='worklog';
	$return['post']=array();
	$this->session('workerid',$item['id']);
	set_html('title','我的日志');
	exi($return);
}
// js 获取数据
if($_RQ['op']=='worklog'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if(isset($_RQ['istop'])){
		$params['istop']=intval($_RQ['istop']);
		$return['params']['istop']=$_RQ['istop'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_workliu_worklog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as $k=>&$v){
		$v['title']=$v['title']?:$v['kehuname'];
		$v['content']=$v['msg'];
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$return['user_buystatus']=$this->user_buystatus;
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='worklist'){
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if(isset($_RQ['istop'])){
		$params['istop']=intval($_RQ['istop']);
		$return['params']['istop']=$_RQ['istop'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_workliu_worklist',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as $k=>&$v){
		$v['content']=$v['msg'];
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='genjinlist'){
	$workerid=$this->session('workerid');
	$params=array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$workerid);
	if(isset($_RQ['istop'])){
		$params['istop']=intval($_RQ['istop']);
		$return['params']['istop']=$_RQ['istop'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_scrm_worker_linelog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as $k=>&$v){
		$v['worker']=pdo_get('jy_scrm_worker',array('id'=>$v['workerid'],'uniacid'=>$_SESSION['uniacid']),array('id','name'));	
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$return['user_buystatus']=$this->user_buystatus;
	$return['list']=$list;
	exi($return);
}
?>